package com.teachsys.tms.service;
import com.teachsys.tms.dao.StudentDao;
import com.teachsys.tms.entity.Student;
import com.teachsys.tms.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("studentService")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public List<Student> queryAll() {
        return this.studentDao.queryAll();
    }

    @Override
    public Student queryById(String id) {
        return this.studentDao.queryById(id);
    }

    @Override
    public Student insert(Student student) {
        this.studentDao.insert(student);
        return this.studentDao.queryById(student.getId());
    }

    @Override
    public Student update(Student student) {
        this.studentDao.update(student);
        return this.queryById(student.getId());
    }

    @Override
    public boolean delete(String id) {
        return this.studentDao.delete(id)>0;
    }
}
